package com.romotc.qqrobot.webqq.qqInterfaceCall.dataProcessor;

import org.json.JSONObject;

import com.romotc.qqrobot.bean.QQLogedin;
import com.romotc.qqrobot.webqq.bean.Search_qq_by_uin2_ResponseBody;
import com.romotc.scache.RequestSpy;


/**
 * 调用获取uin接口后的处理类
 * @author Administrator
 *
 */
public class Search_qq_by_uin2_Processor implements UiOptionDateProcessor{

	
	public final static String Key_Rt_Search_qq_by_uin2_ResponseBody = "Bean_Search_qq_by_uin2_ResponseBody";
	@Override
	public String printJavaScriptFunction() {
		// TODO Auto-generated method stub
		return null;
	}

	/**
	 * 返回界面操作的函数 和调用
	 */
	@Override
	public String execJavascript(Object... params) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public JSONObject processResponse(QQLogedin loginQQ, 
				RequestSpy rqSpy, JSONObject reqDataObj) {
		// TODO Auto-generated method stub
		String resStr = rqSpy.getResBody();
		//{"retcode":0,"result":{"face":579,"birthday":{"month":2,"year":1985,"day":23},"occupation":"","phone":"","allow":1,"college":"","reg_time":0,"constel":0,"blood":0,"stat":20,"homepage":"","country":"中国","city":"","uiuin":"13361004869","personal":"","nick":"唐荣军","shengxiao":0,"email":"","token":"2515519f4a68195d0fee6e80644d3e13ed9e7640dbc110a8","province":"","account":2761004869,"gender":"male","tuin":2859600327,"mobile":"133********"}}
		//{"retcode":0,
				//"result":
					//{"face":579,
						//"birthday":
								//{"month":2,"year":1985,"day":23},
						//"occupation":"","phone":"","allow":1,"college":"",
						//"reg_time":0,"constel":0,"blood":0,"stat":20,"homepage":"",
                		//"country":"中国","city":"","uiuin":"13361004869","personal":"",
						//"nick":"唐荣军","shengxiao":0,"email":"",
		                //"token":"a1c9ae57022a1ae286db2eff0a8ae1b6d53b399bd122a671",
                		//"province":"","account":2761004869,"gender":"male","tuin":155913685,
		                //"mobile":"133********"
		            //}
		//}
		
		try {
			Search_qq_by_uin2_ResponseBody resObject = Search_qq_by_uin2_ResponseBody.parseFromJsonStr(resStr);
			if(resObject == null)
				return reqDataObj;
			
			if(resObject.getRetcode() == 0) {
//				JSONObject retObj = new JSONObject();
				reqDataObj.put(Key_Rt_Search_qq_by_uin2_ResponseBody , resObject);
				return reqDataObj;
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		return reqDataObj;
	}

	private static Search_qq_by_uin2_Processor instance;
	public static synchronized Search_qq_by_uin2_Processor getInstance() {
		if(instance == null)
			instance = new Search_qq_by_uin2_Processor();
		
		return instance;
	}

}
